package com.bpf.base.service.system;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.bpf.base.util.MapUtil;
import com.bpf.base.dao.system.TSysSetDao;
import com.bpf.base.model.system.TSysSet;

/**
 * TODO 本代码由代码生成工具生成
 * @date 2016-07-19 05:31:26
 */
@Service
public class TSysSetService{

	private Logger logger = LoggerFactory.getLogger(TSysSetService.class);
     
    @Resource
	private TSysSetDao tSysSetDao;
	
	//根据条件搜索记录
	public Map<String , Object> getTSysSetList(Map<String, Object> params){
		Map<String , Object> queryMap = new HashMap<String, Object>();
		Map<String , Object> resultMap = new HashMap<String, Object>();
		//TODO 根据需要封装查询需要的条件
		queryMap.putAll(params);
		resultMap.put("rows", tSysSetDao.selectList(queryMap));
		resultMap.put("total", tSysSetDao.selectCount(queryMap));
		return resultMap;
	}
       
	//新增记录
	public int addTSysSet(Map<String, Object> params){
		try {
			//TODO 根据需要封装查询需要的条件
			TSysSet temp=MapUtil.toObject(TSysSet.class, params);
			return tSysSetDao.insert(temp);
		} catch (Exception e) {
			logger.error("添加失败",e);
			return -1;
		}
	}
	
	//更新记录
	public int updateTSysSet(TSysSet tSysSet){
		return tSysSetDao.update(tSysSet);
	}
	
	//删除记录
	public int delTSysSet(Map<String, Object> params){
		return tSysSetDao.deleteByMap(params);
	}
	
	//根据主键批量删除
	public int delTSysSetBat(String[] idArray){
		for(String pk:idArray){
			tSysSetDao.deleteByPk(pk);
		}
		return idArray.length;
	}
	
	public List<TSysSet> getAllTSysSet(Map<String, Object> params){
		return tSysSetDao.selectList(params);
	}
	
	public void clearSys(){
		tSysSetDao.clearSys();
	}
}
